﻿@using Plotly.Blazor.LayoutLib
@using Plotly.Blazor.LayoutLib.XAxisLib
@using Plotly.Blazor.Traces.CandlestickLib
@using Line = Plotly.Blazor.Traces.CandlestickLib.DecreasingLib.Line
<PlotlyChart Id="TestId" Config="config" Layout="layout" Data="data" @ref="chart"/>

@code
{
    PlotlyChart chart;

    Config config = new Config
    {
        Responsive = true
    };

    Layout layout = new Layout
    {
        DragMode = DragModeEnum.Zoom,
        Margin = new Margin
        {
            R = 10,
            T = 25,
            B = 40,
            L = 60
        },
        ShowLegend = true,
        Title = new Title
        {
            Text = "Candlestick"
        },
        XAxis = new List<XAxis>
        {
            new XAxis
            {
                AutoRange = AutoRangeEnum.True,
                Domain = new List<object> {0, 1},
                Range = new List<object> {"2017-01-03 12:00", "2017-02-15 12:00"},
                RangeSlider = new RangeSlider
                {
                    Range = new object[] {"2017-01-03 12:00", "2017-02-15 12:00"}
                },
                Title = new LayoutLib.XAxisLib.Title
                {
                    Text = "Date"
                },
                Type = TypeEnum.Date
            }
        },
        YAxis = new List<YAxis>
        {
            new YAxis
            {
                AutoRange = LayoutLib.YAxisLib.AutoRangeEnum.True,
                Domain = new List<object> {0, 1},
                Range = new List<object> {114.609999778, 137.410004222},
                Type = LayoutLib.YAxisLib.TypeEnum.Linear
            }
        },
        Height = 500
    };

    List<ITrace> data = new List<ITrace>
    {
        new Candlestick
        {
            X = new List<object> {new DateTime(2017, 1, 4), new DateTime(2017, 1, 5), new DateTime(2017, 1, 6), new DateTime(2017, 1, 9), new DateTime(2017, 1, 10), new DateTime(2017, 1, 11), new DateTime(2017, 1, 12), new DateTime(2017, 1, 13), new DateTime(2017, 1, 17), new DateTime(2017, 1, 18), new DateTime(2017, 1, 19), new DateTime(2017, 1, 20), new DateTime(2017, 1, 23), new DateTime(2017, 1, 24), new DateTime(2017, 1, 25), new DateTime(2017, 1, 26), new DateTime(2017, 1, 27), new DateTime(2017, 1, 30), new DateTime(2017, 1, 31), new DateTime(2017, 2, 1), new DateTime(2017, 2, 2), new DateTime(2017, 2, 3), new DateTime(2017, 2, 6), new DateTime(2017, 2, 7), new DateTime(2017, 2, 8), new DateTime(2017, 2, 9), new DateTime(2017, 2, 10), new DateTime(2017, 2, 13), new DateTime(2017, 2, 14), new DateTime(2017, 2, 15)},
            Close = new List<object> {116.019997, 116.610001, 117.910004, 118.989998, 119.110001, 119.75, 119.25, 119.040001, 120, 119.989998, 119.779999, 120, 120.080002, 119.970001, 121.879997, 121.940002, 121.949997, 121.629997, 121.349998, 128.75, 128.529999, 129.080002, 130.289993, 131.529999, 132.039993, 132.419998, 132.119995, 133.289993, 135.020004, 135.509995},
            Decreasing = new Decreasing
            {
                Line = new Line
                {
                    Color = "#7F7F7F"
                }
            },
            High = new List<object> {116.510002, 116.860001, 118.160004, 119.43, 119.379997, 119.93, 119.300003, 119.620003, 120.239998, 120.5, 120.089996, 120.449997, 120.809998, 120.099998, 122.099998, 122.440002, 122.349998, 121.629997, 121.389999, 130.490005, 129.389999, 129.190002, 130.5, 132.089996, 132.220001, 132.449997, 132.940002, 133.820007, 135.089996, 136.270004},
            Increasing = new Increasing
            {
                Line = new Traces.CandlestickLib.IncreasingLib.Line
                {
                    Color = "rgba(31,119,180,1)"
                }
            },
            Low = new List<object> {115.75, 115.809998, 116.470001, 117.940002, 118.300003, 118.599998, 118.209999, 118.809998, 118.220001, 119.709999, 119.370003, 119.730003, 119.769997, 119.5, 120.279999, 121.599998, 121.599998, 120.660004, 120.620003, 127.010002, 127.779999, 128.160004, 128.899994, 130.449997, 131.220001, 131.119995, 132.050003, 132.75, 133.25, 134.619995},
            Open = new List<object> {115.849998, 115.919998, 116.779999, 117.949997, 118.769997, 118.739998, 118.900002, 119.110001, 118.339996, 120, 119.400002, 120.449997, 120, 119.550003, 120.419998, 121.669998, 122.139999, 120.93, 121.150002, 127.029999, 127.980003, 128.309998, 129.130005, 130.539993, 131.350006, 131.649994, 132.460007, 133.080002, 133.470001, 135.520004},
            XAxis = "x",
            YAxis = "y"
        }
    };
}